/**
 * 用途         :囊括了一些常用的数学方法
 * 开发者       :郑品延
 * 修改时间     :2019/8/6
 */
export default class MathUtil{
    public static Pdistance(pointA, pointB) {
        var dx = Math.abs(pointA.x - pointB.x);
        var dy = Math.abs(pointA.y - pointB.y);
        var dis = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
        return dis;
    }
    public static Sin(angle){
        // if (cc.ENGINE_VERSION.indexOf('2.1') >= 0){
        //     return -Math.sin( angle *( Math.PI / 180) );
        // }
        // else
        return Math.sin( angle *( Math.PI / 180) );
    }
    public static Cos(angle){
        return Math.cos( angle *( Math.PI / 180) );
    }
    public static Radian(angle){
        return angle *( Math.PI / 180) ;
    }
    public static CheckNumNaN(localNum){
        let result = 0;
        if (localNum == 'NaN') {
            result = 0;
        }
        else {
            result = parseInt(localNum);
            if (isNaN(result)) {
                result = 0;
            }
        }
        return result;
    }
    public static vec3to2(ve3:cc.Vec3){
        let vec2 = new cc.Vec2(ve3.x,ve3.y);
        return vec2;
    }
}
window['Pdistance'] = MathUtil.Pdistance;
window['CheckNumNaN'] = MathUtil.CheckNumNaN;
window['Sin'] = MathUtil.Sin;
window['Cos'] = MathUtil.Cos;
window['Radian'] = MathUtil.Radian;
window['Vec3to2'] = MathUtil.vec3to2;
